package com.sharer.last.controller;

import com.sharer.last.annotation.OperationLogger;
import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.R;
import com.sharer.last.interfaces.ValidateGroup;
import com.sharer.last.model.dto.persondetail.PersonalDetailUpdateDTO;
import com.sharer.last.model.vo.personDetail.PersonalDetailVO;
import com.sharer.last.service.PersonalDetailService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 关于我
 *
 * @ClassName PersonalDetailAdminController
 * @Author WangJin
 * @Date 2023/05/09/9:30
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_ADMIN_API + "/personal/detail")
public class PersonalDetailAdminController {
    @Resource
    PersonalDetailService personalDetailService;

    /**
     * 获取关于我页面配置
     *
     * @return
     */
    @GetMapping("/getPersonalDetailInfo")
    public R<PersonalDetailVO> getPersonalDetailInfo() {
        return R.ok(personalDetailService.getPersonalDetailInfo());
    }

    /**
     * 修改关于我页面
     *
     * @param personalDetailUpdateDTO
     * @return
     */
    @OperationLogger("修改关于我页面")
    @PutMapping("/update")
    public R updateAbout(@RequestBody @Validated(ValidateGroup.UpdateGroup.class) PersonalDetailUpdateDTO personalDetailUpdateDTO) {
        personalDetailService.updateAbout(personalDetailUpdateDTO);
        return R.handle();
    }
}
